package main

import (
	_ "fmt"
	"io"
	"log"
	"net/http"
)

func HelloServer(w http.ResponseWriter, req *http.Request) {
	token := req.Header.Get("token")
	w.Header().Set("token", token)
	io.WriteString(w, "hello, world!\n")
	io.WriteString(w, "获取 header 中 token的值："+token)
}

func main() {
	http.HandleFunc("/hello", HelloServer)
	err := http.ListenAndServe(":12345", nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
